<?php
namespace Common\Models;
use Common\BaseModel;
class CollegeZan extends BaseModel
{
    public $res;
    public $key;
    public function getSource()
    {
        return "f_college_zan";
    }

    public function initialize()
    {
        parent::initialize();
    }



    /**
     * 当前内容的点赞数
     */
    public function find_count($carousel_id){
        $conditions="carousel_id={$carousel_id}";
        $count_number = $this::count(
            array(
                $conditions,
                "cloumns"=>'id',
                "limit"=>1,
            )
        );
        return $count_number;
    }

    /**
     * 当前内容的点赞数
     */
    public function is_zan($user_id,$carousel_id){
        $conditions="user_id=$user_id and carousel_id={$carousel_id}";
        $count_number = $this::count(
            array(
                $conditions,
                "cloumns"=>'id',
                "limit"=>1,
            )
        );
        return $count_number;
    }

    /**
     * 获取具体的内容
     * @param int $cid 栏目id
     * @param int $cateid 分类id
     * @param int $is_recommend 是否首页推荐
     * @return mixed
     */
    public function find_list($cid=0,$cateid=0,$is_recommend=0){
        $conditions='is_show=1';
        if($cid){
            $conditions .= " AND cid={$cid}";
        }
        if($cateid){
            $conditions .= " AND cateid={$cateid}";
        }
        if($is_recommend){
            $conditions .= " AND is_recommend={$is_recommend}";
        }
        $order="id ASC,sort ASC";
        $user_list = $this::find(
            array(
                $conditions,
                "order" => $order,
            )
        )->toarray();
        return $user_list;
    }





}
